import org.junit.Test;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class ContextPool {
    @Test
    public void contextPool() throws NamingException, SQLException {
        String prefix = "java:comp/env/";
        Context context = new InitialContext();

        DataSource dataSource = (DataSource) context.lookup(prefix + "jdbc/shoppingDS");
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
    }
}
